<template>
	<!-- reg/childern -->
	<div ref=wrapper>
		<div class="content">
			<slot></slot>
		</div>
	</div>
</template>

<script>
	import BScroll from 'better-scroll'

	export default {
		name: 'Scroll',
		props: {
			probeType: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				scroll: null,
				message: '一一一'
			}
		},
		mounted() {
			// 1.创建BScroll对象
			this.scroll = new BScroll(this.$refs.wrapper, {
				click: true,
				probeType: this.probeType,
				pullUpload:true,
				// scroll 2.0 以上版本需要添加才可以滚动
				observeDOM: true
			});

			// 2 监听滚动的位置
			this.scroll.on('scroll', (position) => {
				// console.log(position);
				this.$emit('scroll', position)
			})
			
			// 3  监听上拉事件
		},
		methods: {
			scrollTo(x, y, time = 500) {
				this.scroll.scrollTo(x, y, time);
			},
		},
	}
</script>

<style>
</style>
